package rexsee.script;

import java.util.ArrayList;

public class BlockSwitch extends AbstractBlock {

	private final ArrayList<BlockCondition> childs = new ArrayList<BlockCondition>();

	public BlockSwitch(AbstractBlock parent, String script) {
		super(parent, script);
	}

	@Override
	public int getChildCount(int index) {
		return childs.size();
	}

	@Override
	public AbstractBlock getChild(int index) {
		return childs.get(index);
	}

	@Override
	public Object run() {
		for (int i = 0; i < childs.size(); i++) {
			Object rtn = childs.get(i).run();
			if (rtn instanceof Boolean && ((Boolean) rtn) == true) break;
		}
		return null;
	}

}
